﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Error : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Exception caughtException = (System.Exception)Application["TheException"];
        lblMessage.Text = String.Format("Message: {0}", caughtException.Message);
        if ((Application["DebugInformations"] as bool?) == true)
        {
            lblSource.Text = String.Format("Source: {0}", caughtException.Source);
            lblStacktrace.Text = String.Format("StackTrace: {0}", caughtException.StackTrace);
            lblInnerException.Text = String.Format("InnerException: {0}", (caughtException.InnerException == null ? "" : caughtException.InnerException.Message));
            lblData.Text = String.Format("Data: {0}", caughtException.Data);
            lblTargetSite.Text = String.Format("TargetSite: {0}", caughtException.TargetSite);
            Label1.Text = Label1.Text + " " + ClientQueryString;
        }
        if ((Application["TraceExceptions"] as bool?) == true)
        {
            System.Diagnostics.Trace.Write(String.Format("{2}[{0}] - Data: {1}{2}HelpLink:{3}{2}InnerException:{4}{2}Message:{5}{2}Source:{6}{2}StackTrace:{7}{2}TargetSite:{8}{2}",
                DateTime.Now,
                caughtException.Data,
                System.Environment.NewLine,
                caughtException.HelpLink,
                caughtException.InnerException,
                caughtException.Message,
                caughtException.Source,
                caughtException.StackTrace,
                caughtException.TargetSite));
        }
    }
}